package com.it.service.impl;

import com.it.mapper.CCommentMapper;
import com.it.mapper.CPostMapper;
import com.it.mapper.CReplyMapper;
import com.it.pojo.CComment;
import com.it.pojo.CPost;
import com.it.pojo.CReply;
import com.it.service.MytidingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
public class MytidingServiceImpl implements MytidingService {
    @Resource
    CCommentMapper cCommentMapper;
    @Resource
    CPostMapper cPostMapper;
    @Resource
    CReplyMapper cReplyMapper;

    @Override
    public List<CPost> selectAllByUid(Integer uid) {

        return cPostMapper.selectAllByUid(uid);
    }

    @Override
    public List<CPost> selectByUid(List<CComment> list, Integer uid) {
        List<CPost> plist=new ArrayList<CPost>();
        for (CComment cComment: list) {
            CPost cPost = cPostMapper.selectByPrimaryKey(cComment.getInitiatorid());
            plist.add(cPost);
        }
        return plist;
    }


    @Override
    public List<CComment> selectAllbyInitiatorid(Integer initiatorid) {
        return cCommentMapper.selectAllbyInitiatorid(initiatorid);
    }

    @Override
    public List<CComment> selectByPid(List<CReply> list, Integer pid) {
        List<CComment> clist=new ArrayList<CComment>();
        for (CReply cReply: list) {
            CComment cComment = cCommentMapper.selectByPrimaryKey(cReply.getId());
            clist.add(cComment);
        }
        return clist;
    }

    @Override
    public List<CReply> selectAllByRepliedid(Integer repliedid) {
        return cReplyMapper.selectAllByRepliedid(repliedid);
    }
}
